#define _CRT_SECURE_NO_WARNING
#include <stdio.h>
int main()
{
    int n;
    int sum = 0;
    int k = 0;
    int c = 0;
    scanf("%d", &n);
    while (n != 0)
    {
        sum += n;
        k = n / 2;
        c = c + n % 2;
        n = 0;
        if (c == 2)
        {
            n++;
            c = 0;
        }
        n = k;
    }
    printf("%d", sum);
    return 0;
}